#include "LightShip.hpp"
#include "Entity3D.hpp"
#include "HostileEntityStateNames.hpp"
#include <iostream>

using namespace std;

LightShip::LightShip(string modelName, string textureName, float fFlySpeed, MVector3D initPos) : HostileEntity(modelName, textureName)
{
	//MVector3D initialPosition;
	//initialPosition.x = 0.0f; initialPosition.y = 30.0f; initialPosition.z = 0.0f;

	setHitPoints(140);
	setPosition(initPos);
	m_flySpeed = fFlySpeed;
	Hostile::setHostileType(LIGHT_SHIP);
}

LightShip::~LightShip()
{
}

void LightShip::setFlySpeed(float speed)
{
	m_flySpeed = speed;
}

void LightShip::update(clock_t tick)
{
	static bool dead = false;
	//static clock_t ticker = 0;
	HostileEntity::getStateMachine()->updateMFSM(tick);
	MVector3D translation;

	if(HostileEntity::getStateMachine()->getCurrentState()->getStateName() == HESN_EXPLODE ||
		HostileEntity::getStateMachine()->getCurrentState()->getStateName() == HESN_DIE)
		setVisibility(false);
	/*if(newPosition.z >= 10.0f && !dead)
	{
		dead = true;
		getStateMachine()->changeState(new HostileDie);
	}
	else*/
	{
		translation.z += (tick * (m_flySpeed/2.0f))/1000.0f;
		this->translate(translation);
	}
}

//EOF
